package com.baiytfp.hf.HFDataExchange.action.controller.view;

import com.baiytfp.hf.baiytfp.framework.base.BaseController;
import com.baiytfp.hf.baiytfp.hfutils.HFDBHelper;
import com.baiytfp.hf.baiytfp.hfutils.HFRequest;
import com.baiytfp.hf.HFDataExchange.common.base.anotation.Auth;
import com.baiytfp.hf.HFDataExchange.common.model.base.TableName;
import com.baiytfp.hf.HFDataExchange.common.model.table.Tags;
import com.baiytfp.hf.HFDataExchange.common.model.vo.BaseUserVO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@Controller
@RequestMapping("/view/tags")
public class TagsVController extends BaseController {

	public TagsVController() {

	}

	@RequestMapping("/tagslist")
	@Auth(checkMenu=true)
	public ModelAndView tagslist(HttpServletRequest request,HttpServletResponse response) throws Exception {

		String tag_type = HFRequest.getIstance().getString(request, "tag_type");

		ModelAndView mav = new ModelAndView();

		mav.addObject("tag_type", tag_type);

		return mav;
	}

	@RequestMapping("/tagsedit")
	@Auth(checkMenu=true)
	public ModelAndView tagsedit(HttpServletRequest request, HttpServletResponse response) throws Exception {

		String key = HFRequest.getIstance().getString(request, "itemid");

		if(!"".equals(key) && !"0".equals(key)){	//查看
			Tags itemObj = HFDBHelper.read(TableName.TAGS, Tags.class, key);

			ModelAndView mav = new ModelAndView();
			mav.addObject("item_obj", itemObj);

			mav.addObject("is_read", HFRequest.getIstance().getString(request, "is_read", ""));

			return mav;

		}else{	//新增

			String tag_type = HFRequest.getIstance().getString(request, "tag_type");

			ModelAndView mav = new ModelAndView();

			mav.addObject("item_obj", null);

			mav.addObject("tag_type", tag_type);

			return mav;
		}
	}



}
